package com.yangguang.huahui.ui.fragments;

import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.ListView;

import com.yangguang.huahui.R;
import com.yangguang.huahui.entity.AttentionList;
import com.yangguang.huahui.mvp.presenter.AttentionPresenter;
import com.yangguang.huahui.mvp.view.AttentionView;
import com.yangguang.huahui.ui.activitys.BaseMvpActivity;
import com.yangguang.huahui.ui.adapters.HomeListAdapter;
import com.yangguang.huahui.widget.MyListView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by Administrator on 2017/3/7.
 */

public class AttentionListFragment extends BaseMvpFragment<AttentionView, AttentionPresenter> implements AttentionView{
    private List<AttentionList.ListBean> datas = new ArrayList<>();
    @BindView(R.id.mListView)
    MyListView mListView;
    private HomeListAdapter mAdapter;
    @BindView(R.id.frag_attionList)
    LinearLayout frag_attionList;

    public static AttentionListFragment newInstance(String id) {
        AttentionListFragment fragment = new AttentionListFragment();
        Bundle arguments = new Bundle();
        arguments.putString("id", id);
        fragment.setArguments(arguments);
        return fragment;
    }
    @Override
    public void onSuccess(AttentionList data) {
        if (data.getList() != null){
            datas = data.getList();
        }
        mAdapter = new HomeListAdapter(mActivity, datas, R.layout.find_miaomu_list_item);
        mListView.setAdapter(mAdapter);
    }

    @Override
    public void onError() {

    }

    @Override
    protected AttentionPresenter initPresenter() {
        return new AttentionPresenter();
    }

    @Override
    protected void fetchData() {
        mPresenter.getListData(getArguments().getString("id"));
    }

    @Override
    protected int initLayoutId() {
        return R.layout.frag_attention_list;
    }

    @Override
    protected void initView() {
        frag_attionList.setFocusable(true);
        frag_attionList.setFocusableInTouchMode(true);
        frag_attionList.requestFocus();
    }

    @Override
    protected void initData() {

    }
}
